# ------------------------------------------------------------------

# Title:      Administrative Overload and Policy Triage: Causal Evidence
#             from the Introduction of the Acid Rain Program in the U.S.
# Authors:    Constantin Kaplaner, Christoph Knill, Yves Steinebach
# Journal:    Journal of Public Administration Research and Theory (JPART)

# ------------------------------------------------------------------

# Description:

# This script reproduces all quantitative results and figures from the
# main text and supporting information of the study. The paper uses a
# difference-in-differences (DiD) design to identify trade-offs in EPA
# inspection behavior following the phased rollout of the U.S. Acid Rain
# Program. It shows how administrative overload, in the absence of
# compensatory capacity, leads to policy triage: a reallocation of
# enforcement resources away from unaffected industrial plants.

# ------------------------------------------------------------------

# Replication Structure:

# ├── 00_data/ 
# │   ├── 01_data_processed/                  Contains the data prepared for analysis
# │     ├── data_epa_analysis.Rdata           Contains the main data set(s) used for the analysis
# │     ├── epa_empl.Rdata                    Contains the data on employees of the EPA
# │     ├── locations_sites.Rdata             Contains the coordinates of the industrial sites in the sample
# │     ├── policy_growth_data.Rdata          Contains data on the number of additional policies per year
# │     ├── inspection_count.Rdata            Contains data on the number of inspections conducted per year
# │     ├── FRS_ids.csv                       Contains additional information 
# │     ├── phase1sites.csv                   Contains additional information 

# ├── 01_scripts/                
# │   ├── 01_statistical_analysis.R.          Conducts the main analysis
# │   ├── 02_sensitivity_analysis.R           Conducts sensitivity analysis to the violation of parallel trends
# │   ├── 03_map_inspections.R                Creates the map figures
# │   ├── 04_policy_growth.R                  Creates the figures on policy growth
# │   ├── 05_employees_over_time.R            Creates the figures on employee trends used in the main text
# │   ├── 06_administrative_traditions.R      Creates the figure on administrative traditions
# │   ├── 07_treatment_intensity.R            Conducts additional analysis considering treatment intensity
# │   ├── 08_cluster_permutation.R            Conducts sensitivity analysis to difference inference assumptions
# │   ├── 09_model_any_inspections.R          Conducts additional analysis presented in the Supporting Information
# │   ├── 10_employees_over_time_filtered.R   Creates figure on employee trends presented in the Supporting Information
# │   └── 11_treatment_slack.R                Conducts additional analysis considering slack
# │   └── 12_table_function.R                 Creates the tables presented in the Supporting Information

# ├── 03_figures/                             Contains all figures of the main text
# │   ├── appendix/                           Contains all figures in the Supporting Information


# ------------------------------------------------------------------

cat("\nStarting replication pipeline...\n")

# --- Run Main Analyses ------------------------------------------------------

cat("\n1. Running analysis \n")
source("01_scripts/01_statistical_analysis.R")

cat("\n2. Sensitivy analysis: Note warnings pertain only the lower bounds \n")
source("01_scripts/02_sensitivity_analysis.R")

cat("\n3. Mapping of EPA inspection sites \n")
source("01_scripts/03_map_inspections.R")

cat("\n4. Policy growth figure \n")
source("01_scripts/04_policy_growth.R")

cat("\n5. EPA employee count trends over time \n")
source("01_scripts/05_employees_over_time.R")

cat("\n6. Cross-national administrative traditions \n")
source("01_scripts/06_administrative_traditions.R")

# --- Heterogeneity and Alternate Outcomes -----------------------------------

cat("\n7. Treatment intensity by regional burden \n")
source("01_scripts/07_treatment_intensity.R")

cat("\n8. Permutation inference and cluster-robust state-level errors \n")
source("01_scripts/08_cluster_permutation.R")

cat("\n9. Additional analysis \n")
source("01_scripts/09_model_any_inspections.R")

cat("\n10. Relevant employees trend over time \n")
source("01_scripts/10_employees_over_time_filtered.R")

cat("\n11. Treatment by administrative slack \n")
source("01_scripts/11_treatment_slack.R")

cat("\n12. Creates the tables in the Supporting Information\n")
source("01_scripts/12_table_function.R")


# --- Save Session Info ------------------------------------------------------

cat("\nSaving session information to '03_figures/session_info.txt'...\n")
sink("03_figures/session_info.txt")
sessionInfo()
sink()

# --- Wrap-up ----------------------------------------------------------------

cat("\nReplication complete. All analyses successfully executed.\n")
